//
//  FunctionVC.m
//  NewProject
//
//  Created by 李航飞 on 2017/6/4.
//  Copyright © 2017年 李航飞. All rights reserved.
//

#import "FunctionVC.h"
#import "FirstTableViewCell.h"
#import "SecondTableViewCell.h"
#import "ShopModel.h"
#import "ShopInfoViewController.h"
#import "FirstCellModel.h"



@interface FunctionVC ()<UITableViewDataSource, UITableViewDelegate,UITextFieldDelegate,UIScrollViewDelegate>
@property (nonatomic,strong) NSMutableArray *arr;
@property (nonatomic,strong) NSMutableArray *arr1;
@property (nonatomic,strong) NSMutableArray *erJiArr;
@property (nonatomic,strong) UITableView *firsttableView;
@property (nonatomic,strong) UITableView *secondtableView;

@property (nonatomic, strong)NSMutableArray *modelArray;
@property (nonatomic, strong)NSMutableArray *secondModelArray;
@property (nonatomic, strong)UITableView *tableView;

@property (nonatomic, strong)UILabel *biaoShi;
@property (nonatomic, assign)BOOL isLoad;

@property (nonatomic, strong)UIView *topView;
@property (nonatomic, strong)UIView *appearView;
//@property (nonatomic, strong)UISwipeGestureRecognizer *panGesture;
@property (nonatomic, assign)long height;
@end

@implementation FunctionVC

- (NSMutableArray *)modelArray{
    if (!_modelArray) {
        _modelArray = [NSMutableArray array];
    }
    return _modelArray;
}
- (NSMutableArray *)secondModelArray{
    if (!_secondModelArray) {
        _secondModelArray = [NSMutableArray array];
    }
    return _secondModelArray;
}
- (void)viewWillAppear:(BOOL)animated
{
    
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden=YES;
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    _isLoad=NO;
    [self firstGetMessage];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    //self.navigationItem.title = @"功能";
    self.title=@"闪送超市";
    
}
- (void)setUpView{
    _topView = [[UIView alloc]init];
    _topView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_topView];
    
    _appearView = [[UIView alloc]init];
    _appearView.backgroundColor = [UIColor whiteColor];
    _appearView.frame = CGRectMake(WIDTH-270*kScrenWidth, 64, 270/WIDTH_6_SCALE, 51);
    _appearView.hidden = YES;
//    _appearView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:_appearView];
    
    UILabel *holderLabel = [[UILabel alloc]init];
    holderLabel.text = @"综合排序";
    holderLabel.font = FONT(13);
    [_appearView addSubview:holderLabel];
    
    [holderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_appearView.mas_left).offset(70/WIDTH_6_SCALE);
        make.centerY.equalTo(_appearView.mas_centerY);
    }];
    
    UIView *navView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)];
    [self.view addSubview:navView];
    navView.backgroundColor=[UIColor whiteColor];
    
    UIView *dingWei=[[UIView alloc] initWithFrame:CGRectMake(0, 0, navView.frame.size.width/2, 64)];
    [navView addSubview:dingWei];
    UIImageView *dingWeiImg=[[UIImageView alloc] initWithFrame:CGRectMake(18*kScrenWidth, 30, 15, 20)];
    [dingWeiImg setImage:[UIImage imageNamed:@"biao@x2"]];
    [dingWei addSubview:dingWeiImg];
    UILabel *dingWeiLab=[[UILabel alloc] initWithFrame:CGRectMake(dingWeiImg.frame.size.width+dingWeiImg.frame.origin.x+5, 30, dingWei.frame.size.width-dingWeiImg.frame.size.width-dingWeiImg.frame.origin.x-5, 20)];
    [dingWeiLab setFont:[UIFont systemFontOfSize:14]];
    dingWeiLab.text=@"和泰大厦 >";
    UILabel *lineLab=[[UILabel alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 1)];
    lineLab.backgroundColor=LINE_COLOE_245;
    [self.view addSubview:lineLab];
    
    //    UIInputView *searchInput=[[UIInputView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2, 30, self.view.frame.size.width/2, 20)];
    //    [self.view addSubview:searchInput];
    //    searchInput.backgroundColor=LINE_COLOE;
    UIView *searchInput =[[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2, 25, self.view.frame.size.width/2-15, 30)];
    searchInput.backgroundColor=LINE_COLOE_245;
    //    searchInput.delegate=self;
    //    searchInput.clearButtonMode=YES;
    //    [searchInput setFont:[UIFont systemFontOfSize:14]];
    //    searchInput.placeholder = @"请输入商品名称";
    //    searchInput.keyboardType=UIKeyboardTypePhonePad;
    UIImageView *imageViewPwd=[[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 20, 20)];
    [searchInput addSubview:imageViewPwd];
    imageViewPwd.image=[UIImage imageNamed:@"dax2"];
    UITextField *searchField=[[UITextField alloc] initWithFrame:CGRectMake(imageViewPwd.frame.size.width+imageViewPwd.frame.origin.x+10, 5, self.view.frame.size.width/2-(imageViewPwd.frame.size.width+imageViewPwd.frame.origin.x+10+15), 20)];
    searchField.delegate=self;
    //    searchField.backgroundColor=LINE_COLOE_245;
    searchField.clearButtonMode=YES;
    [searchField setFont:[UIFont systemFontOfSize:14]];
    searchField.placeholder = @"请输入商品名称";
    [searchInput addSubview:searchField];
    //    searchInput.keyboardType=UIKeyboardTypePhonePad;
    //    searchInput.leftView=imageViewPwd;
    //    searchInput.leftView.frame=CGRectMake(10, 5, 10, 10);
    //    searchInput.leftViewMode=UITextFieldViewModeAlways; //此处用来设置leftview现实时机
    //    searchInput.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    searchInput.layer.borderColor=[UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1].CGColor;
    searchInput.layer.borderWidth= 1.0f;
    searchInput.layer.cornerRadius = 15.0f;
    [self.view addSubview:searchInput];
    
    [dingWei addSubview:dingWeiLab];
    
    UIButton *zhonghepaixu=[[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/4, 0, self.view.frame.size.width/4, 50)];
    [zhonghepaixu setTitle:@"综合排序" forState:UIControlStateNormal];
    [zhonghepaixu.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [zhonghepaixu setTitleColor:[UIColor colorWithRed:21/255.0 green:21/255.0 blue:21/255.0 alpha:1] forState:UIControlStateNormal];
    [_topView addSubview:zhonghepaixu];
    
    UIButton *jiage=[[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/4*2, 0, self.view.frame.size.width/4, 50)];
    [jiage setTitle:@"按价格" forState:UIControlStateNormal];
    [jiage setTitleColor:[UIColor colorWithRed:21/255.0 green:21/255.0 blue:21/255.0 alpha:1] forState:UIControlStateNormal];
    [jiage.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [_topView addSubview:jiage];
    
    UIButton *xiaoliang=[[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/4*3, 0, self.view.frame.size.width/4, 50)];
    [xiaoliang setTitle:@"按销量" forState:UIControlStateNormal];
    [xiaoliang setTitleColor:[UIColor colorWithRed:21/255.0 green:21/255.0 blue:21/255.0 alpha:1] forState:UIControlStateNormal];
    [xiaoliang.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [_topView addSubview:xiaoliang];
    
    UIView *lineView=[[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/4, 49, self.view.frame.size.width/4*3, 1)];
    lineView.backgroundColor=[UIColor colorWithRed:250/255.0 green:250/255.0 blue:250/255.0 alpha:1];
    [_topView addSubview:lineView];
    
}
- (void)setUpViewTwo{
    long a=0;
    if (_erJiArr.count%3==0) {
        a=_erJiArr.count/3;
    }else{
        a=_erJiArr.count/3+1;
    }
    _height = a;
    UIView *erJiFenLeiView=[[UIView alloc] initWithFrame:CGRectMake(WIDTH-270*kScrenWidth, 51, 270*kScrenWidth, a*37*kScrenHidth+15*kScrenHidth)];
    [_topView addSubview:erJiFenLeiView];
    
    //    for (int x=0; x<_erJiArr.count/3; x++) {
    //        for (int y=0; y<3; y++) {
    //            UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(15+(15+70)*y, 15+(15+22)*x, 70, 22)];
    //            [btn setTitle:[NSString stringWithFormat:@"%@", _erJiArr[x*3+y][@"name"]] forState:UIControlStateNormal];
    //            [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //            btn.backgroundColor=ORANGE_COLOR;
    //            [erJiFenLeiView addSubview:btn];
    //        }
    //    }
    for (int x=0; x<_erJiArr.count; x++) {
        UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake((15+(15+70)*(x%3))/WIDTH_6_SCALE, (15+(15+22)*(x/3))/WIDTH_6_SCALE, 70/WIDTH_6_SCALE, 22/WIDTH_6_SCALE)];
        [btn setTitle:[NSString stringWithFormat:@"%@", _erJiArr[x][@"name"]] forState:UIControlStateNormal];
        btn.titleLabel.font = FONT(13);
        [btn setTitleColor:RGB0X(0xC8C8C8) forState:UIControlStateNormal];
//        btn.backgroundColor=ORANGE_COLOR;
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        btn.layer.masksToBounds = YES;
        btn.layer.cornerRadius = 2/WIDTH_6_SCALE;
        btn.layer.borderColor = RGB0X(0xFFD601).CGColor;
        btn.layer.borderWidth = 1/WIDTH_6_SCALE;
        btn.tag=500+x;
        [erJiFenLeiView addSubview:btn];
    }
    UITableView *firsttableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width/4, self.view.frame.size.height-44-64) style:UITableViewStylePlain];
    
#pragma mark --------------
    //    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"111",@"id",@"lhf",@"name", nil];
    //    __weak typeof(self)wkself = self;
    //
    //    for (NSDictionary *dataDict in arr) {
    //
    //        ShopModel *model = [[ShopModel alloc]init];
    //        [model setValuesForKeysWithDictionary:dataDict];
    //
    //        [self.modelArray addObject:model];
    //
    //        [wkself.firsttableView reloadData];
    //    }
#pragma mark --------------
    //    [tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    //去掉tableView自带分割线
    
    firsttableView.separatorStyle =  UITableViewCellSeparatorStyleNone;
    firsttableView.dataSource = self;
    firsttableView.delegate = self;
    firsttableView.tag = 100000;
    firsttableView.rowHeight=50;
    [self.view addSubview:firsttableView];
    _biaoShi=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 5*kScrenWidth, 50)];
    _biaoShi.backgroundColor=ALL_COLOR;
    [firsttableView addSubview:_biaoShi];
    _firsttableView=firsttableView;
    _topView.frame = CGRectMake(0,64, self.view.frame.size.width, erJiFenLeiView.frame.size.height+erJiFenLeiView.frame.origin.y);

    UITableView *secondtableView = [[UITableView alloc] initWithFrame:CGRectMake(firsttableView.frame.size.width,erJiFenLeiView.frame.size.height+erJiFenLeiView.frame.origin.y+64, self.view.frame.size.width/4*3, self.view.frame.size.height-50-64-44) style:UITableViewStylePlain];
    //    arr=[@"和泰大厦",@"和泰大厦",@"和泰大厦",@"和泰大厦",nil];
    
    //    [tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    //去掉tableView自带分割线
    secondtableView.rowHeight=90;
    secondtableView.separatorStyle =  UITableViewCellSeparatorStyleNone;
    secondtableView.dataSource = self;
    secondtableView.delegate = self;
    secondtableView.tag = 100001;
    [self.view addSubview:secondtableView];
    _secondtableView=secondtableView;
    
//    _panGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeGestureRecognizer:)];
//    _panGesture.direction = UISwipeGestureRecognizerDirectionUp;
//    [_secondtableView addGestureRecognizer:_panGesture];
}
//网络请求
- (void)firstGetMessage{
    AFHTTPSessionManager*manager=[AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = nil;
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    manager.responseSerializer.acceptableContentTypes =  [NSSet setWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript",@"text/plain", nil];
    
    NSString*urlstr=[NSString stringWithFormat:@"http://www.lnwuyou.com/sc/index.php?g=portal&m=goods&a=category_p"];
    [manager GET:urlstr parameters:nil  progress:nil success:^(NSURLSessionDataTask *operation, id responseObject) {
        NSLog(@"111%@",responseObject);
        NSDictionary*dic=[[NSDictionary alloc]init];
        dic=responseObject;
        _arr=dic[@"data"];
        if ([dic[@"status"] isEqualToString:@"1"]) {
            __weak typeof(self)wkself = self;
            for (NSDictionary *dataDict in _arr) {
                
                ShopModel *model = [[ShopModel alloc]init];
                [model setValuesForKeysWithDictionary:dataDict];
                
                [self.modelArray addObject:model];
                
                [wkself.firsttableView reloadData];
            }
            [self secondGetMessage:@"1"];
        }
        
    } failure:^(NSURLSessionDataTask *operation, NSError *error) {
        NSLog(@"Error: %@", error);
        NSLog(@"请求出错了: - %@ \n%@",
              [error localizedDescription],
              [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
    }];

}
- (void)secondGetMessage:(NSString *)pid{
    AFHTTPSessionManager*manager=[AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = nil;
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    manager.responseSerializer.acceptableContentTypes =  [NSSet setWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript",@"text/plain", nil];
    
    NSString*urlstr=[NSString stringWithFormat:@"http://www.lnwuyou.com/sc/index.php?g=portal&m=goods&a=category_c&pid=%@",pid];
    [manager GET:urlstr parameters:nil  progress:nil success:^(NSURLSessionDataTask *operation, id responseObject) {
        NSLog(@"2222%@",responseObject);
        NSDictionary*dic=[[NSDictionary alloc]init];
        dic=responseObject;
        _erJiArr=dic[@"data"];
        if ([dic[@"status"] isEqualToString:@"1"]) {
//            __weak typeof(self)wkself = self;
//            for (NSDictionary *dataDict in _arr1) {
//                
//                FirstCellModel *model = [[FirstCellModel alloc]init];
//                [model setValuesForKeysWithDictionary:dataDict];
//                
//                [self.secondModelArray addObject:model];
//                
//                [wkself.secondtableView reloadData];
//            }
            [self thirdGetMessage:pid];
        }else{
            NSLog(@"2222%@",dic[@"msg"]);
        }
        
    } failure:^(NSURLSessionDataTask *operation, NSError *error) {
        NSLog(@"Error: %@", error);
        NSLog(@"请求出错了: - %@ \n%@",
              [error localizedDescription],
              [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
    }];
    
}
- (void)thirdGetMessage :(NSString *)pid{
    AFHTTPSessionManager*manager=[AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = nil;
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    manager.responseSerializer.acceptableContentTypes =  [NSSet setWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript",@"text/plain", nil];
    
    NSString*urlstr=[NSString stringWithFormat:@"http://www.lnwuyou.com/sc/index.php?g=portal&m=goods&a=goodslist&sid=1&catid=%@&sort=price&turn=desc",pid];
    [manager GET:urlstr parameters:nil  progress:nil success:^(NSURLSessionDataTask *operation, id responseObject) {
        NSLog(@"333%@",responseObject);
        NSDictionary*dic=[[NSDictionary alloc]init];
        dic=responseObject;
        _arr1=dic[@"data"];
        if ([dic[@"status"] isEqualToString:@"1"]) {
            __weak typeof(self)wkself = self;
            for (NSDictionary *dataDict in _arr1) {
                
                FirstCellModel *model = [[FirstCellModel alloc]init];
                [model setValuesForKeysWithDictionary:dataDict];
                
                [self.secondModelArray addObject:model];
                
                [wkself.secondtableView reloadData];
            }
            if (_isLoad==YES) {
//                [self ];
            }else{
                [self setUpView];
                [self setUpViewTwo];
            }
            
        }else{
            NSLog(@"3333%@",dic[@"msg"]);
        }
        
    } failure:^(NSURLSessionDataTask *operation, NSError *error) {
        NSLog(@"Error: %@", error);
        NSLog(@"请求出错了: - %@ \n%@",
              [error localizedDescription],
              [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
    }];
    
}
#pragma mark -- UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (tableView==_firsttableView) {
        return _arr.count;
    }else{
        return 11;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView == _firsttableView) {
        NSLog(@"%ld",indexPath.row);
        
        _biaoShi.frame=CGRectMake(0, 50*indexPath.row, 5*kScrenWidth, 50);
        ShopModel *model = self.modelArray[indexPath.row];
        [self secondGetMessage:model.pid];
    }else if (tableView==_secondtableView){
        ShopInfoViewController *shopInfo=[[ShopInfoViewController alloc] init];
        self.tabBarController.tabBar.hidden=YES;
        [self.navigationController pushViewController:shopInfo animated:YES];
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //    static NSString *myCellIdentifer = @"myCell";
    //    UITableViewCell *cell = nil;
    if(tableView==_firsttableView){
        static NSString*iden=@"cell";
        FirstTableViewCell *cell=[[FirstTableViewCell alloc]initWithResueIdentifier:iden];
        if (!cell) {
            cell = [[FirstTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:iden];
        }
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
//        cell.messageLabel.text=_arr[indexPath.row];
        
        
        ShopModel *model = self.modelArray[indexPath.row];
        cell.messageLabel.text = model.name;
        if ([model.level isEqualToString:@"HOT"]) {
            cell.isShowImage = YES;
            [cell.hotImg setImage:[UIImage imageNamed:@"hot"]];
        }
        return cell;

    }
    
        NSString*iden1=[NSString stringWithFormat:@"cell%ld%ld",indexPath.section,indexPath.row];
//        SecondTableViewCell *cell1=[[SecondTableViewCell alloc] :iden1];
    SecondTableViewCell *cell1=[tableView dequeueReusableCellWithIdentifier:iden1];
        if (!cell1) {
            cell1 = [[SecondTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:iden1]   ;
        }
        cell1.selectionStyle=UITableViewCellSelectionStyleNone;
        return cell1;
    
//    cell.hotImg=[UIImage imageNamed:@"hotx2"];
    
    
//    cell1.messageLabel.text=_arr[indexPath.row];
    //    cell = [tableView dequeueReusableCellWithIdentifier:myCellIdentifer];
    //
    //
    //    if (!cell) {
    //        cell = [[DingWeiTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:myCellIdentifer];
    //    }
    
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

//- (void)swipeGestureRecognizer:(UISwipeGestureRecognizer *)sender{
//    if (sender.direction == UISwipeGestureRecognizerDirectionUp) {
//        if (_secondtableView.contentOffset.x == 0) {
//            [UIView animateWithDuration:0.5 animations:^{
//                _topView.frame = CGRectMake(0,-_height*37*kScrenHidth+15*kScrenHidth, self.view.frame.size.width/4*3, _topView.frame.size.height);
//                _secondtableView.frame = CGRectMake(_secondtableView.frame.origin.x, _secondtableView.frame.origin.y -_height*37*kScrenHidth+15*kScrenHidth, _secondtableView.frame.size.width, _secondtableView.frame.size.height);
//            }];
//        }
//    }
//    return;
//}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (scrollView.tag == 100001) {
        if (_topView.frame.origin.y==64&&scrollView.contentOffset.y>0) {
            [UIView animateWithDuration:0.5 animations:^{
                _topView.frame = CGRectMake(0,64-_height*37*kScrenHidth-15*kScrenHidth, self.view.frame.size.width/4*3, _topView.frame.size.height);
                _secondtableView.frame = CGRectMake(_secondtableView.frame.origin.x, _topView.frame.size.height -_height*37*kScrenHidth-15*kScrenHidth+64, _secondtableView.frame.size.width, _secondtableView.frame.size.height);
            }completion:^(BOOL finished) {
                _topView.hidden = YES;
                _appearView.hidden = NO;
            }];
            [scrollView setContentOffset:CGPointMake(0, 0)];
            [self.view bringSubviewToFront:_appearView];
        }
        if (_topView.frame.origin.y!=64&&scrollView.contentOffset.y<0) {
            _topView.hidden = NO;
            _appearView.hidden = YES;
            [UIView animateWithDuration:0.5 animations:^{
                _topView.frame = CGRectMake(0,64, self.view.frame.size.width/4*3, _topView.frame.size.height);
                _secondtableView.frame = CGRectMake(_secondtableView.frame.origin.x, _topView.frame.size.height+64, _secondtableView.frame.size.width, _secondtableView.frame.size.height);
            } completion:^(BOOL finished) {
            }];
            [scrollView setContentOffset:CGPointMake(0, 0)];
        }
    }
}
#pragma marl -- UITableViewDelegate
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    return 50;
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)btnClick:(UIButton *)sender{
    for (int x = 0 ; x<_erJiArr.count; x++) {
        UIButton *button = [self.view viewWithTag:500+x];
        button.backgroundColor = [UIColor whiteColor];
        [button setTitleColor:RGB0X(0xC8C8C8) forState:UIControlStateNormal];
    }
    [sender setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    sender.backgroundColor = RGB0X(0xFFD601);
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
